<%inherit file="/base.mako"/>

<%def name="head()">
<script type="text/javascript" src="/media/js/jquery.tablesorter.min.js"></script> 
<script type="text/javascript">
$(function() {
	$("table.sortable").tablesorter({
		headers : {
			2 : {sorter: 'text'}
		}
	});
})
</script>
<style type='text/css'>
	#commands {
		float: right;
		margin: 0;
		list-style: none;
	}

	#commands li {
		float: left;
		margin-left: 30px;
	}
</style>
</%def>


<%def name="content()">
<ul id="commands">
	<li><a href="/you_tube_partial_parse/retry/${c.parse.video_id}">Retry</a></li>
	<li><a href="/you_tube_partial_parse/delete/${c.parse.video_id}">Delete</a></li>
</ul>
<table>
	<thead>
		<tr>
			<th>Name</th>
			<th>Value</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>Video ID</td>
			<td><a href="http://www.youtube.com/watch?v=${c.parse.video_id}">${c.parse.video_id}</a></td>
		</tr>
		<tr>
			<td>Time</td>
			<td>${c.parse.time.strftime('%Y-%m-%d %I:%M %p')}</td>
		</tr>
		<tr>
			<td>Title</td>
			<td>${c.parse.title}</td>
		</tr>
		<tr>
			<td>Date Played</td>
			<td>
			% if len(c.parse.date_played) == 0:
				<p>None</p>
			% else:
				<ul>
				% for d in c.parse.date_played:
					<li><a href="${h.kespa.schedule(d)}">${d.strftime('%Y-%m-%d')}</a></li>
				% endfor
				</ul>
			% endif
			</td>
		</tr>
		<tr>
			<td>Teams</td>
			<td>${c.parse.teams}</td>
		</tr>
		<tr>
			<td>Players</td>
			<td>
			% if len(c.parse.players) == 0:
				<p>None</p>
			% else:
				<ul>
				% for p in c.parse.players:
					<li>
						<a href="${h.kespa.player(p)}">${p}</a>
					</li>
				% endfor
			% endif
		</tr>
		<tr>
			<td>Game Number</td>
			<td>${c.parse.game_number}</td>
		</tr>
		<tr>
			<td>Possible Results</td>
			<td>
			% if len(c.parse.possible_results) == 0:
				<p>None</p>
			% else:
				<table class="sortable">
					<thead>
						<tr>
							<th>League</th>
							<th>Stage Path</th>
							<th>Date Played</th>
							<th>Team One</th>
							<th>Team Two</th>
							<th>Player One</th>
							<th>Player Two</th>
							<th>Game Number</th>
						</tr>
					</thead>
					<tbody>
						% for index, result in enumerate(c.parse.possible_results):
						<tr>
							<td>${result.get('league', '')}</td>
							<td>${'/'.join(result.get('stage_path', ''))}</td>
							<td>
								<a href="${h.kespa.schedule(result['date_played'])}">${result['date_played'].strftime('%Y-%m-%d')}</a>
							</td>
							<td>${result['team_one']}</td>
							<td>${result['team_two']}</td>
							<td>
								<a href="${h.kespa.player(result['player_one'])}">${result['player_one']}
							</td>
							<td>
								<a href="${h.kespa.player(result['player_two'])}">${result['player_two']}
							</td>
							<td>${result['game_number']}</td>
						</tr>
						% endfor
					</tbody>
				</table>
			% endif
			</td>
		</tr>
	</tbody>
</table>
</%def>
